package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ResReviewImg;
import com.ruoyi.system.service.IResReviewImgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐馆评论图片Controller
 * 
 * @author ruoyi
 * @date 2025-05-30
 */
@RestController
@RequestMapping("/system/resreimg")
public class ResReviewImgController extends BaseController
{
    @Autowired
    private IResReviewImgService resReviewImgService;

    /**
     * 查询餐馆评论图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:resreimg:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResReviewImg resReviewImg)
    {
        startPage();
        List<ResReviewImg> list = resReviewImgService.selectResReviewImgList(resReviewImg);
        return getDataTable(list);
    }

    /**
     * 导出餐馆评论图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:resreimg:export')")
    @Log(title = "餐馆评论图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResReviewImg resReviewImg)
    {
        List<ResReviewImg> list = resReviewImgService.selectResReviewImgList(resReviewImg);
        ExcelUtil<ResReviewImg> util = new ExcelUtil<ResReviewImg>(ResReviewImg.class);
        util.exportExcel(response, list, "餐馆评论图片数据");
    }

    /**
     * 获取餐馆评论图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resreimg:query')")
    @GetMapping(value = "/{imgId}")
    public AjaxResult getInfo(@PathVariable("imgId") Long imgId)
    {
        return success(resReviewImgService.selectResReviewImgByImgId(imgId));
    }

    /**
     * 新增餐馆评论图片
     */
    @PreAuthorize("@ss.hasPermi('system:resreimg:add')")
    @Log(title = "餐馆评论图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResReviewImg resReviewImg)
    {
        return toAjax(resReviewImgService.insertResReviewImg(resReviewImg));
    }

    /**
     * 修改餐馆评论图片
     */
    @PreAuthorize("@ss.hasPermi('system:resreimg:edit')")
    @Log(title = "餐馆评论图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResReviewImg resReviewImg)
    {
        return toAjax(resReviewImgService.updateResReviewImg(resReviewImg));
    }

    /**
     * 删除餐馆评论图片
     */
    @PreAuthorize("@ss.hasPermi('system:resreimg:remove')")
    @Log(title = "餐馆评论图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imgIds}")
    public AjaxResult remove(@PathVariable Long[] imgIds)
    {
        return toAjax(resReviewImgService.deleteResReviewImgByImgIds(imgIds));
    }
}
